{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=912
  Verdict: Accepted
}
var a:array[1..50] of int64; n,i:longint;
begin
assign(input,'input.txt');
assign(output,'output.txt');
reset(input);
rewrite(output);
read(n);
a[1]:=2;
a[2]:=4;
a[3]:=7;
for i:=4 to n do a[i]:=a[i-1]+a[i-2]+a[i-3];
write(a[n]);
end.